import random
ls1 = random.choices(range(1,21),k=20)
result = dict.fromkeys(range(1,21),0)
for i in ls1:
    result[i]+=1

i = 1
ls2 = []
while i < len(result) - 1:
    ls2.append((result[i],i))
    i+=1
ls3 = sorted(ls2,reverse=1)
for i in range(3):
    print("vaules: {}, times: {}".format(ls3[i][1],ls3[i][0]))

# 做的不错